<!DOCTYPE html>
<html lang="zh-CN" xmlns="http://www.w3.org/1999/html">
<head>
    <title>账户提现</title>
    <link rel="shortcut icon" href="/static/favicon.ico" type="image/x-icon">
    <link rel="stylesheet" type="text/css" href="/static/css/public.css?v202204271231">
    <link rel="stylesheet" type="text/css" href="/static/qdxwx/css/global.css?v202204271231">
    <link rel="stylesheet" type="text/css" href="/static/qdxwx/css/web.css?v202204271231">
    <link rel="stylesheet" type="text/css" href="/static/qdxwx/css/theme.css?v202204271231">
    <link rel="stylesheet" type="text/css" href="/static/libs/layui-v2.6.8/css/layui.css" />
    <script type="text/javascript" src="/static/libs/jquery/jquery-3.6.0.min.js"></script>
    <script type="text/javascript" src="/static/libs/layui-v2.6.8/layui.js"></script>
</head>
<body>
<div class="pl15 pr15">
    <ul class='l-r-w-Inpt l-r-w-Inpt-tx'>
        <li class="li-one hLh30" style="border-bottom: 1px solid #e2e2e2">
            <tt class="vam fsize14 c-999 f-fM">
                <#if userAddress.id gt 0>
                         编辑地址
                    <#else>
                         添加地址
                </#if>
            </tt>
        </li>
        <li class="mt20  tac">
            <label class='vam'><b style="color: red;margin-right: 3px"></b>省市地区：</label>
            <input style="width: 350px" placeholder="如：广东省惠州市惠城区" type='text' id='province' name='province' value="${userAddress.province!}" class='lTxt'>
        </li>
        <li class="mt20  tac">
            <label class='vam'><b style="color: red;margin-right: 3px"></b>详细地址：</label>
            <input style="width: 350px" placeholder="如：XXX路XXX小区A301等" type='text' id="address" name='address' value="${userAddress.address!}" class='lTxt'>
        </li>
        <li class="mt20  tac">
            <label class='vam'><b style="color: red;margin-right: 3px"></b>收件人：</label>
            <input style="width: 350px" placeholder="请输入收件人姓名" type='text' id='userName' name='userName' value="${userAddress.userName!}" class='lTxt'>
        </li>
        <li class="mt20  tac">
            <label class='vam'><b style="color: red;margin-right: 3px"></b>联系电话：</label>
            <input style="width: 350px"  placeholder="请输入收件人联系方式" type='text' id='mobile' name='mobile' value="${userAddress.mobile!}" class='lTxt'>
        </li>
        <li class='mt30 btn-list tac clear pt15'>
            <label class='vam'>&nbsp;</label>
            <span class='login-btn l-b-small mr20'>
                <input type="hidden" id="addressId" name="id" value="${userAddress.id!}">
                <input type='button' onclick="saveAddress()" value='保 存'>
            </span>
        </li>
    </ul>
</div>
<script type="text/javascript">

    function saveAddress() {
        var province = $("#province").val();
        var address = $("#address").val();
        var userName = $("#userName").val();
        var mobile = $("#mobile").val();
        var addressId = $("#addressId").val();
        if (province == null || province === "") {
            return layer.msg("请输入省市地区");
        }
        if (address == null || address === "") {
            return layer.msg("请输入详细收件地址" );
        }
        if (userName == null || userName === "") {
            return layer.msg("请输入收件人姓名");
        }
        if (mobile == null || mobile === "") {
            return layer.msg("请输入收件人联系方式");
        }
        var data = {"id":addressId, "province": province, "address": address, "userName": userName, "mobile": mobile};
        $.post("/user/address/save.json", data, function (json) {
                if (json.code === 0) {
                    return layer.alert("恭喜您，收件地址保存成功！", function () {
                        parent.layer.closeAll();
                        parent.location.reload();
                    });
                } else {
                    return layer.alert("失败：" + json.msg);
                }
        })
    }
</script>
</body>
</html>